﻿using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Input;

namespace VSTweaker.UI.ViewModels
{
    public class ExternalToolsViewModel : INotifyPropertyChanged
    {
        public ExternalToolsViewModel(VisualStudioVersion version)
        {
            if (version == null)
            {
                return;
            }

            AvailableTools = new ObservableCollection<ExternalTool>(ExternalTool.GetAll(version.Version, version.Instance));
        }

        private ExternalTool _selectedTool;
        private ObservableCollection<ExternalTool> _availableTools;

        public ObservableCollection<ExternalTool> AvailableTools
        {
            get { return _availableTools; }
            set
            {
                _availableTools = value;
                OnPropertyChaned("AvailableTools");
            }
        }

        public ExternalTool SelectedTool
        {
            get { return _selectedTool; }
            set 
            {
                _selectedTool = value;
                OnPropertyChaned("SelectedTool");
            }
        }

        //public ICommand AddNewCommand
        //{
        //    get
        //    {
                
        //    }
        //}

        private void OnPropertyChaned(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }


        public event PropertyChangedEventHandler PropertyChanged;
    }
}
